﻿using PMS.Domain.Exceptions;
using PMS.Domain.Seedwork;
using System;
using System.Collections.Generic;
using System.Text;

namespace PMS.Domain.AggregatesModel.MessaeAggregate
{
    /// <summary>
    /// 消息领域  记录系统消息
    /// </summary>
    public class MessageCenter:Entity,IAggregateRoot
    {

        /// <summary>
        /// 接收人
        /// </summary>
        public int UserId { get; set; }

        /// <summary>
        /// 消息标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 消息内容
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }
        /// <summary>
        /// 消息状态
        /// </summary>
        public bool Comfirmed { get; set; }

        /// <summary>
        /// 已读时间
        /// </summary>
        public DateTime ComfirmedTime { get; set; }

        public MessageCenter() { }

        public MessageCenter(int userId, string title,string message)
        {
            if(userId == default(int))
            {
                throw new PMSDomainException("要设定消息接收人");
            }
            if(string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(message))
            {
                throw new PMSDomainException("必须设定消息标题，消息内容！");
            }
            UserId = userId;
            Title = title;
            Message = message;
            CreatedTime = DateTime.Now;
        }
    }
}
